/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            housekeepingServPoolPayInfo: {
                housekeepingServPools: [],
                total: 0,
                records: 1,
                moreCondition: false,
                conditions: {
                    servName: '',
                    state: '1400',
                    applyName: '',
                    applyTel: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that._listHousekeepingServPays(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('housekeepingServPoolPay', 'listHousekeepingServPool', function (_param) {
                $that._listHousekeepingServPays(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listHousekeepingServPays(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listHousekeepingServPays: function (_page, _rows) {
                $that.housekeepingServPoolPayInfo.conditions.page = _page;
                $that.housekeepingServPoolPayInfo.conditions.row = _rows;
                var param = {
                    params: $that.housekeepingServPoolPayInfo.conditions
                };
                param.params.servName = param.params.servName.trim();
                param.params.applyName = param.params.applyName.trim();
                param.params.applyTel = param.params.applyTel.trim();
                //发送get请求
                vc.http.apiGet('/housekeepingServPool/queryHousekeepingServPool',
                    param,
                    function (json, res) {
                        var _housekeepingServPoolPayInfo = JSON.parse(json);
                        $that.housekeepingServPoolPayInfo.total = _housekeepingServPoolPayInfo.total;
                        $that.housekeepingServPoolPayInfo.records = _housekeepingServPoolPayInfo.records;
                        $that.housekeepingServPoolPayInfo.housekeepingServPools = _housekeepingServPoolPayInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.housekeepingServPoolPayInfo.records,
                            dataCount: $that.housekeepingServPoolPayInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryHousekeepingServPoolMethod: function () {
                $that._listHousekeepingServPays(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetHousekeepingServPoolMethod: function () {
                $that.housekeepingServPoolPayInfo.conditions.servName = "";
                $that.housekeepingServPoolPayInfo.conditions.applyName = "";
                $that.housekeepingServPoolPayInfo.conditions.applyTel = "";
                $that._listHousekeepingServPays(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _toPay: function (_pool) {
                vc.jumpToPage('/#/pages/goods/housekeepingServPoolPayOrder?poolId=' + _pool.poolId + "&servName=" + _pool.servName)
            },
            _moreCondition: function () {
                if ($that.housekeepingServPoolPayInfo.moreCondition) {
                    $that.housekeepingServPoolPayInfo.moreCondition = false;
                } else {
                    $that.housekeepingServPoolPayInfo.moreCondition = true;
                }
            },
            _openDetail: function (_pool) {
                vc.jumpToPage('/#/pages/goods/housekeepingServDetail?poolId=' + _pool.poolId)
            }
        }
    });
})(window.vc);
